package com.cdtu.store.oss;

//import com.aliyun.oss.OSS;
//import com.aliyun.oss.OSSClientBuilder;

/**
 * @author dongyuhao
 */
//@RunWith(SpringRunner.class)
//@SpringBootTest(classes = StoreApplication.class)
public class SyncImage {
    //@Autowired
    //private SkuService skuService;
    //@Test
    //public void test(){
    //    String endpoint = "https://oss-cn-chengdu.aliyuncs.com";
    //    String accessKeyId = "LTAI4GD4LabYEwuTwBuYyGgd";
    //    String accessKeySecret = "hGDS3NDAgcDLfuhQz5MveV81k1U045";
    //    String bucketName = "cdtushixun";
    //    String imageUrl = "https://cdtushixun.oss-cn-chengdu.aliyuncs.com/";
    //    OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    //    List<SkuEntity> skus = skuService.list();
    //    skus.forEach(sku -> {
    //        if(!sku.getImages().contains("group")){
    //            int images = sku.getImages().indexOf("images");
    //            System.out.println("images::"+sku.getImages());
    //            String iamgeSub = sku.getImages().substring(images, sku.getImages().length());
    //            System.out.println(iamgeSub);
    //            String file = "C:/Users/Administrator/Desktop/"+iamgeSub;
    //            FileInputStream fis = null;
    //            try {
    //                fis = new FileInputStream(file);
    //            } catch (FileNotFoundException e) {
    //                e.printStackTrace();
    //            }
    //            String updateImg = imageUrl+iamgeSub;
    //            ossClient.putObject(bucketName, iamgeSub, fis);
    //            sku.setImages(updateImg);
    //            skuService.updateById(sku);
    //        }
    //    });
    //}

}
